{"ast":null,"code":"import _slicedToArray from\"/Users/poppie/Desktop/development/messenger/app/frontend/node_modules/@babel/runtime/helpers/esm/slicedToArray.js\";import React from'react';import classNames from\"classnames\";import{Modal,UserItem}from\"../index\";import{observer}from\"mobx-react-lite\";import{Context}from\"../../index\";import'./ContactItem.scss';import{jsx as _jsx}from\"react/jsx-runtime\";import{jsxs as _jsxs}from\"react/jsx-runtime\";var ContactItem=function ContactItem(props){var _React$useContext=React.useContext(Context),store=_React$useContext.store;var _React$useState=React.useState(false),_React$useState2=_slicedToArray(_React$useState,2),showModalOnRequest=_React$useState2[0],setShowModalOnRequest=_React$useState2[1];var _React$useState3=React.useState(false),_React$useState4=_slicedToArray(_React$useState3,2),showModalOnSent=_React$useState4[0],setShowModalOnSent=_React$useState4[1];var _React$useState5=React.useState(false),_React$useState6=_slicedToArray(_React$useState5,2),showModalOnAll=_React$useState6[0],setShowModalOnAll=_React$useState6[1];if(props.addRequest){return/*#__PURE__*/_jsxs(\"div\",{className:classNames(\"contacts__item\",\"contacts__item-add-requests\"),children:[props.currentUser.id===props.contact.toUser.id&&/*#__PURE__*/_jsx(UserItem,{profile:props.contact.fromUser})||/*#__PURE__*/_jsx(UserItem,{profile:props.contact.toUser}),/*#__PURE__*/_jsxs(\"div\",{className:\"contacts__item-control\",children:[/*#__PURE__*/_jsx(\"button\",{className:classNames(\"contacts__item-control-button\",\"contacts__item-control-button-accept\"),onClick:function onClick(){return store.acceptContactFromAPI(props.contact,props.index);}}),/*#__PURE__*/_jsx(\"button\",{className:classNames(\"contacts__item-control-button\",\"contacts__item-control-button-delete\"),onClick:function onClick(){setShowModalOnRequest(true);}}),/*#__PURE__*/_jsx(Modal,{active:showModalOnRequest,title:\"Удаление входящей заявки\",hasFunctionButtons:true,onSubmit:function onSubmit(){store.deleteContactFromAPI(props.contact,props.index).then(function(){return setShowModalOnRequest(false);});},onClose:function onClose(){return setShowModalOnRequest(false);},customClassNameButtonSecond:\"messenger__sidebar-profileControl-deleteProfile\",children:/*#__PURE__*/_jsx(\"div\",{children:\"\\u0412\\u044B \\u0434\\u0435\\u0439\\u0441\\u0442\\u0432\\u0438\\u0442\\u0435\\u043B\\u044C\\u043D\\u043E \\u0445\\u043E\\u0442\\u0438\\u0442\\u0435 \\u0431\\u0435\\u0437\\u0432\\u043E\\u0437\\u0432\\u0440\\u0430\\u0442\\u043D\\u043E \\u0443\\u0434\\u0430\\u043B\\u0438\\u0442\\u044C \\u0437\\u0430\\u044F\\u0432\\u043A\\u0443?\"})})]})]});}else if(props.sentRequest){return/*#__PURE__*/_jsxs(\"div\",{className:classNames(\"contacts__item\",\"contacts__item-sent-requests\"),children:[props.currentUser.id===props.contact.toUser.id&&/*#__PURE__*/_jsx(UserItem,{profile:props.contact.fromUser})||/*#__PURE__*/_jsx(UserItem,{profile:props.contact.toUser}),/*#__PURE__*/_jsxs(\"div\",{className:\"contacts__item-control\",children:[/*#__PURE__*/_jsx(\"button\",{className:classNames(\"contacts__item-control-button\",\"contacts__item-control-button-delete\"),onClick:function onClick(){setShowModalOnSent(true);}}),/*#__PURE__*/_jsx(Modal,{active:showModalOnSent,title:\"Удаление исходящей заявки\",hasFunctionButtons:true,onSubmit:function onSubmit(){store.deleteContactFromAPI(props.contact,props.index).then(function(){return setShowModalOnSent(false);});},onClose:function onClose(){return setShowModalOnSent(false);},customClassNameButtonSecond:\"messenger__sidebar-profileControl-deleteProfile\",children:/*#__PURE__*/_jsx(\"div\",{children:\"\\u0412\\u044B \\u0434\\u0435\\u0439\\u0441\\u0442\\u0432\\u0438\\u0442\\u0435\\u043B\\u044C\\u043D\\u043E \\u0445\\u043E\\u0442\\u0438\\u0442\\u0435 \\u0431\\u0435\\u0437\\u0432\\u043E\\u0437\\u0432\\u0440\\u0430\\u0442\\u043D\\u043E \\u0443\\u0434\\u0430\\u043B\\u0438\\u0442\\u044C \\u0437\\u0430\\u044F\\u0432\\u043A\\u0443?\"})})]})]});}else{return/*#__PURE__*/_jsxs(\"div\",{className:classNames(\"contacts__item\",\"contacts__item-all-accepted\"),children:[props.currentUser.id===props.contact.toUser.id&&/*#__PURE__*/_jsx(UserItem,{profile:props.contact.fromUser})||/*#__PURE__*/_jsx(UserItem,{profile:props.contact.toUser}),/*#__PURE__*/_jsx(\"div\",{className:\"contacts__item-control\",children:/*#__PURE__*/_jsx(\"button\",{className:classNames(\"contacts__item-control-button\",\"contacts__item-control-button-delete\"),onClick:function onClick(){setShowModalOnAll(true);}})}),/*#__PURE__*/_jsx(Modal,{active:showModalOnAll,title:\"Удаление контакта\",hasFunctionButtons:true,onSubmit:function onSubmit(){store.deleteContactFromAPI(props.contact,props.index).then(function(){return setShowModalOnAll(false);});},onClose:function onClose(){return setShowModalOnAll(false);},customClassNameButtonSecond:\"messenger__sidebar-profileControl-deleteProfile\",children:/*#__PURE__*/_jsx(\"div\",{children:\"\\u0412\\u044B \\u0434\\u0435\\u0439\\u0441\\u0442\\u0432\\u0438\\u0442\\u0435\\u043B\\u044C\\u043D\\u043E \\u0445\\u043E\\u0442\\u0438\\u0442\\u0435 \\u0431\\u0435\\u0437\\u0432\\u043E\\u0437\\u0432\\u0440\\u0430\\u0442\\u043D\\u043E \\u0443\\u0434\\u0430\\u043B\\u0438\\u0442\\u044C \\u043A\\u043E\\u043D\\u0442\\u0430\\u043A\\u0442?\"})})]});}};export default observer(ContactItem);","map":{"version":3,"names":["React","classNames","Modal","UserItem","observer","Context","ContactItem","props","useContext","store","useState","showModalOnRequest","setShowModalOnRequest","showModalOnSent","setShowModalOnSent","showModalOnAll","setShowModalOnAll","addRequest","currentUser","id","contact","toUser","fromUser","acceptContactFromAPI","index","deleteContactFromAPI","then","sentRequest"],"sources":["/Users/poppie/Desktop/development/messenger/app/frontend/src/components/ContactItem/index.tsx"],"sourcesContent":["import React from 'react';\nimport classNames from \"classnames\";\nimport {ContactItemProps} from \"../../models/props/ContactItemProps\";\nimport {Modal, UserItem} from \"../index\";\nimport {observer} from \"mobx-react-lite\";\nimport {Context} from \"../../index\";\nimport './ContactItem.scss';\n\nconst ContactItem: React.FC<ContactItemProps> = (props) => {\n    const {store} = React.useContext(Context);\n    const [showModalOnRequest, setShowModalOnRequest] = React.useState<boolean>(false);\n    const [showModalOnSent, setShowModalOnSent] = React.useState<boolean>(false);\n    const [showModalOnAll, setShowModalOnAll] = React.useState<boolean>(false);\n\n    if (props.addRequest) {\n        return (\n            <div className={classNames(\"contacts__item\", \"contacts__item-add-requests\")}>\n                {(props.currentUser.id === props.contact.toUser.id &&\n                        <UserItem profile={props.contact.fromUser} />\n                    ) ||\n                    <UserItem profile={props.contact.toUser} />\n                }\n                <div className=\"contacts__item-control\">\n                    <button className={classNames(\"contacts__item-control-button\",\n                        \"contacts__item-control-button-accept\")}\n                        onClick={() => store.acceptContactFromAPI(props.contact, props.index)}\n                    />\n                    <button className={classNames(\"contacts__item-control-button\",\n                        \"contacts__item-control-button-delete\")}\n                        onClick={() => {\n                            setShowModalOnRequest(true);\n                        }}\n                    />\n                    <Modal\n                        active={showModalOnRequest}\n                        title={\"Удаление входящей заявки\"}\n                        hasFunctionButtons={true}\n                        onSubmit={() => {\n                            store.deleteContactFromAPI(props.contact, props.index).then(() =>\n                                setShowModalOnRequest(false)\n                            );\n                        }}\n                        onClose={() => setShowModalOnRequest(false)}\n                        customClassNameButtonSecond={\"messenger__sidebar-profileControl-deleteProfile\"}\n                    >\n                        <div>Вы действительно хотите безвозвратно удалить заявку?</div>\n                    </Modal>\n                </div>\n            </div>\n        );\n    } else if (props.sentRequest) {\n        return (\n            <div className={classNames(\"contacts__item\", \"contacts__item-sent-requests\")}>\n                {(props.currentUser.id === props.contact.toUser.id &&\n                        <UserItem profile={props.contact.fromUser} />\n                    ) ||\n                    <UserItem profile={props.contact.toUser} />\n                }\n                <div className=\"contacts__item-control\">\n                    <button className={classNames(\"contacts__item-control-button\",\n                        \"contacts__item-control-button-delete\")}\n                        onClick={() => {\n                            setShowModalOnSent(true);\n                        }}\n                    />\n                    <Modal\n                        active={showModalOnSent}\n                        title={\"Удаление исходящей заявки\"}\n                        hasFunctionButtons={true}\n                        onSubmit={() => {\n                            store.deleteContactFromAPI(props.contact, props.index).then(() =>\n                                setShowModalOnSent(false)\n                            );\n                        }}\n                        onClose={() => setShowModalOnSent(false)}\n                        customClassNameButtonSecond={\"messenger__sidebar-profileControl-deleteProfile\"}\n                    >\n                        <div>Вы действительно хотите безвозвратно удалить заявку?</div>\n                    </Modal>\n                </div>\n            </div>\n        );\n    } else {\n        return (\n            <div className={classNames(\"contacts__item\", \"contacts__item-all-accepted\")}>\n                {(props.currentUser.id === props.contact.toUser.id &&\n                        <UserItem profile={props.contact.fromUser} />\n                    ) ||\n                    <UserItem profile={props.contact.toUser} />\n                }\n                <div className=\"contacts__item-control\">\n                    <button className={classNames(\"contacts__item-control-button\",\n                        \"contacts__item-control-button-delete\")}\n                        onClick={() => {\n                            setShowModalOnAll(true);\n                        }}\n                    />\n                </div>\n                <Modal\n                    active={showModalOnAll}\n                    title={\"Удаление контакта\"}\n                    hasFunctionButtons={true}\n                    onSubmit={() => {\n                        store.deleteContactFromAPI(props.contact, props.index).then(() =>\n                            setShowModalOnAll(false)\n                        );\n                    }}\n                    onClose={() => setShowModalOnAll(false)}\n                    customClassNameButtonSecond={\"messenger__sidebar-profileControl-deleteProfile\"}\n                >\n                    <div>Вы действительно хотите безвозвратно удалить контакт?</div>\n                </Modal>\n            </div>\n        );\n    }\n}\n\nexport default observer(ContactItem);"],"mappings":"8IAAA,MAAOA,MAAK,KAAM,OAAO,CACzB,MAAOC,WAAU,KAAM,YAAY,CAEnC,OAAQC,KAAK,CAAEC,QAAQ,KAAO,UAAU,CACxC,OAAQC,QAAQ,KAAO,iBAAiB,CACxC,OAAQC,OAAO,KAAO,aAAa,CACnC,MAAO,oBAAoB,CAAC,wFAE5B,GAAMC,YAAuC,CAAG,QAA1CA,YAAuC,CAAIC,KAAK,CAAK,CACvD,sBAAgBP,KAAK,CAACQ,UAAU,CAACH,OAAO,CAAC,CAAlCI,KAAK,mBAALA,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